﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ztn_iot_sdk_cSharp.req;
using ztn_iot_sdk_cSharp.res;

namespace ztn_iot_sdk_cSharp.tool
{
    class IotDeviceTool
    {

        private const string BASE_PATH = "iot/api/v1/v1/device/";

        public static List<DeviceStatus> batchDeviceStatus(DeviceBatchStatusReq req)
        {
            string path = BASE_PATH + "batchDeviceStatus";
            BaseRes<List<DeviceStatus>> res = HttpTool.doPost<BaseRes<List<DeviceStatus>>>(path, JsonTool.toJson(req));
            if (null != res && null != res.data)
            {
                return res.data;
            }
            return new List<DeviceStatus>();
        }

        public static List<Device> list(DeviceListReq req)
        {
            string path = BASE_PATH + "list";
            BaseRes<List<Device>> res = HttpTool.doPost<BaseRes<List<Device>>>(path, JsonTool.toJson(req));
            if (null != res && null != res.data)
            {
                return res.data;
            }
            return new List<Device>();
        }

        public static Device get(DeviceGetReq req)
        {
            string path = BASE_PATH + "get";
            BaseRes<Device> res = HttpTool.doPost<BaseRes<Device>>(path, JsonTool.toJson(req));
            if (null != res && null != res.data)
            {
                return res.data;
            }
            return null;
        }
    }
}
